package com.xbongbong.saas.enums.dictionary;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * @author jiyonghui
 * @className CouponTempleteStatusEnum
 * @description
 * @date 2020/1/6   14:41
 */
@Getter
public enum MarketingStatusEnum {
    // 上架状态

    ONLINE(0, "enum.couponTempleteStatus.name.online", "online"),
    OFFLINE(1, "enum.couponTempleteStatus.name.offline", "offline"),
    WAIT_ONLINE(2, "enum.couponTempleteStatus.name.wait_online", "waitOnline"),
    ;

    private Integer code;
    private String name;
    private String attr;

    MarketingStatusEnum(Integer code, String name, String attr) {
        this.code = code;
        this.name = name;
        this.attr = attr;
    }


    public static String getByCode(Integer number) {
        for (MarketingStatusEnum marketingStatusEnum : values()) {
            if (Objects.equals(marketingStatusEnum.getCode(), number)) {
                return marketingStatusEnum.getName();
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
